{extend name='table'}

{block name="button"}
<!--{if auth("add")}-->
<button data-modal='{:url("add")}?jxs_code={$jxs_code}' data-table-id="MenuTable" class='layui-btn layui-btn-sm layui-btn-primary'>{:lang('添加区域')}</button>
<!--{/if}-->
{/block}

{block name="content"}
<div class="think-box-shadow">
    <a class="layui-btn layui-btn-sm"  data-rrhref="admin.html#{:url('myr/jxs/index')}" onclick="ajaxareas(this)" style="margin-bottom:15px;" data-title="返回上页" >{:lang('返回上页')}</a>
    
    
    {if($parents["role"] == 1)}
    
    <a class="layui-btn layui-btn-sm"  data-rrhref="admin.html#{:url('myr/xsarea/setarea')}" 
    onclick="setajaxareas(this)" style="margin-bottom:15px;" >设置 {$parents["province"]} 销售范围</a>
    
    {/if}
    
    {if($parents["role"] == 2  || $parents["role"] == 3)}
    
    <a class="layui-btn layui-btn-sm"  data-rrhref="admin.html#{:url('myr/xsarea/setarea')}" 
    onclick="setajaxareas(this)" style="margin-bottom:15px;" >设置 {$parents["city"]} 销售范围</a>
    
    {/if}
    <table id="OplogTable" data-url="{:request()->url()}" data-target-search="form.form-search"></table>
</div>
{/block}

{block name='script'}
<script>
function  ajaxareas(obj){
    var pagesaaa=JSON.parse(window.sessionStorage.getItem("pages2"));
    window.sessionStorage.setItem("pages",JSON.stringify(pagesaaa));
    window.location.href=$(obj).data("rrhref")
}
function  setajaxareas(obj){
   $.ajax({
       url:"{:url('myr/xsarea/setarea')}",
       data:{jxs_code:{$jxs_code}},
       success:function(ret){
           console.log(ret)
       }
   })
   
}
$(function () {
  $('#OplogTable').layTable({
            even: true, height: 'full',
            sort: {field: 'id', type: 'desc'},
            cols: [[
                {checkbox: true},
                {field: 'id', title: '序号', width: 70, sort: true, align: 'center'},
                {field: 'province', title: '{:lang("省份")}',width: 170},
                {field: 'city', title: '{:lang("城市")}',width: 170},
                {field: 'district', title: '{:lang("区县")}',width: 170},
                {toolbar: '#toolbar', title: '{:lang("操作面板")}',width: 300, align: 'center',fixed: 'right'}
            ]]
        });
});
</script>
<!-- 操控面板的模板 -->
<script type="text/html" id="toolbar">
   
    {if auth('edit')}
    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="编辑账号" data-modal='{:url("edit")}?id={{d.id}}'>{:lang('编 辑')}</a>
    {/if}
   
    {if auth('remove')}
    <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除账号吗？" data-action="{:url('remove')}" data-value="id#{{d.id}}"  >删 除</a>
    {/if}

</script>
{/block}